package com.corejava.training.collections.car.pre15.immutable;

import java.util.*;

public class LaptopImmutableDemo {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		// create 3 instances of LaptopImmutable
		LaptopImmutable lapImmutable1 = new LaptopImmutable("Dell", "Latitude", "Windows XP", 2.6);
		LaptopImmutable lapImmutable2 = new LaptopImmutable("HP", "Pavillion", "Windows Vista", 2.4);
		LaptopImmutable lapImmutable3 = new LaptopImmutable("Apple", "Macbook", "Mac OS", 3.0);
		
		// add objects to list and iterate thru the list
		List lapList = new ArrayList();
		lapList.add(lapImmutable3);
		lapList.add(lapImmutable2);
		lapList.add(lapImmutable1);
		
		Iterator ite = lapList.iterator();
		// print out with jdk 1.4 style
		while(ite.hasNext()){
			LaptopImmutable laptopImmutable = (LaptopImmutable)ite.next();
			System.out.println("Company: " + laptopImmutable.getCompany());
			System.out.println("Model: " + laptopImmutable.getModel());
			System.out.println("OS: " + laptopImmutable.getOs());
			System.out.println("Processor: " + laptopImmutable.getProcessor());
			System.out.println("-----------------------------------------");
		}
		
		// create a list with Generics signature and add objects to it
		List<LaptopImmutable> laptList = new ArrayList<LaptopImmutable>();
		laptList.add(lapImmutable3);
		laptList.add(lapImmutable2);
		laptList.add(lapImmutable1);
		
		// print out objects
		for (LaptopImmutable laptopImmutable : laptList) {
			 System.out.println("START WITH JDK 1.5 STYLE");
			 System.out.println("Company: " + laptopImmutable.getCompany());
				System.out.println("Model: " + laptopImmutable.getModel());
				System.out.println("OS: " + laptopImmutable.getOs());
				System.out.println("Processor: " + laptopImmutable.getProcessor());
				System.out.println("-----------------------------------------");
				
		}
		
	}

}
